package com.atguigu.userprofile.mapper;

import com.atguigu.userprofile.bean.UserGroup;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import javax.ws.rs.DELETE;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zhangchen
 * @since 2021-05-04
 */


@Mapper
@DS("mysql")
public interface UserGroupMapper extends BaseMapper<UserGroup> {

    @Insert("${SQL}")
    @DS("clickhouse")
    public void insertUserGroupBitmap(@Param("SQL") String insertBitmapSQL);

    @Select("select bitmapCardinality(us) from user_group where user_group_id=#{id}")
    @DS("clickhouse")
    public Long selectUserGroupCount(@Param("id") String userGroupId);


    @Delete(" alter table user_group delete where user_group_id=#{id}")
    @DS("clickhouse")
    public void deleteUserGroup(@Param("id") String userGroupId);

    @Select("${SQL}")
    @DS("clickhouse")
    public Long selectBitmapCount(@Param("SQL") String bitmapCountSQL);

    @Select("select arrayJoin(bitmapToArray(us)) from user_group where user_group_id=#{id}")
    @DS("clickhouse")
    public  List<String>  selectUserGroupUidList(@Param("id") String userGroupId);


}
